/*  File Name	: ReactorImpl.h
 *  Author		: Pang Jiacai
 *	 E-mail		: 823960168@qq.com
 *  Created on	: 2012-2-2
 *  Description:
 */

#ifndef REACTORIMPL_H_
#define REACTORIMPL_H_
#include "EventHandler.h"

class SignalHanlder;

class ReactorImpl
{
public:
	ReactorImpl();
	virtual ~ReactorImpl();

	//initialization
	virtual int open(int handle_size,int timer_heap_size,SignalHanlder *sh,bool only_timer)=0;

	//reactor run status,1:start 2:stop
	virtual void run_status(int status=0)=0;

	//reactor run status,1:start 2:stop
	virtual int get_run_status(void)=0;

	virtual int handle_events(int timeout=0)=0;

	// i/o handler
	virtual int register_handler(int handle,EventHandler *eh,ReactorMask mask)=0;

	virtual int remove_handler(int handle,EventHandler *eh,ReactorMask mask)=0;

	//signal handler
	virtual int register_signal(int signum,EventHandler *eh,bool replace_old,EventHandler *old_sh)=0;

	virtual int remove_signal(int signum,EventHandler *eh)=0;

	virtual int reactor_type(void)=0;

	//timer
	virtual long schudle_timer(EventHandler *eh,TimeValue delay,TimeValue interval)=0;

	virtual int suspend_timer(long  timer_id) = 0;

	virtual int resume_timer(long timer_id)=0;

	virtual int cancel_timer(long timer_id) = 0;

	virtual int refresh_timer(long  timer_id,TimeValue new_time) = 0;

	virtual RT_MUTEX &lock(void)=0;
};

#endif /* REACTORIMPL_H_ */
